#!/bin/sh /etc/rc.common

START=99

USE_PROCD=1
PROG=/sbin/l2ogre

start_service() {

	config_load network
	config_get wan_ifname wan ifname "eth1"
	config_get wan_ipaddr wan ipaddr "10.10.20.254"

	config_load l2ogre
	config_get enabled tunnel enabled 0
	config_get tunnel tunnel name "L2oGRE"
	config_get remote_server tunnel remote_server "10.10.20.253"

	if [ $enabled -eq 1 ]; then
		ip link add $tunnel type gretap local $wan_ipaddr remote $remote_server dev $wan_ifname
		brctl addif br-lan $tunnel
		ip link set dev $tunnel up
	else
		ip link del $tunnel
	fi
}


stop_service() {
	config_load l2ogre
	config_get tunnel tunnel name "L2oGRE"

	ip link del $tunnel
}
